package org.jerrymouse.financeApp.web;

import java.util.Date;

import javax.annotation.Resource;

import org.jerrymouse.agentContainer.AgentContainer;
import org.jerrymouse.financeApp.FinanceApp;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class TestController {

	@Resource
	private AgentContainer agentContainer;

	@RequestMapping("/test")
	public String test(@RequestParam String no, Model model) {
		Date to = new Date();
		Date from = new Date(to.getTime() - 3153600000l);
		FinanceApp financeApp = (FinanceApp) agentContainer.get(FinanceApp.class);
		financeApp.setNo(no);
		model.addAttribute("companyAvg", financeApp.companyAvg(from, to));
		model.addAttribute("tradeAvg", financeApp.tradeAvg(from, to));
		model.addAttribute("companyVariance", financeApp.companyVariance(from, to));
		model.addAttribute("tradeVariance", financeApp.tradeVariance(from, to));
		return "test";
	}
}
